package com.huaxin.hxcloud.fragment;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.huaxin.common.Entity.HxBulletinList;
import com.huaxin.hxcloud.R;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by hebing on 2017/8/25.
 */

public class HxNoticeListAdapter extends RecyclerView.Adapter<HxNoticeListAdapter.ViewHolder> {

    private       Context                               mContext;
    private final LayoutInflater                        mInflater;
    private       List<HxBulletinList.BulletinListBean> mListBeanList;

    public HxNoticeListAdapter(Context context, List<HxBulletinList.BulletinListBean> ListBeanList) {
        this.mContext = context;
        this.mListBeanList = ListBeanList;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View rootView = mInflater.inflate(R.layout.item_notice, parent, false);
        return new ViewHolder(rootView);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        HxBulletinList.BulletinListBean listBean = mListBeanList.get(position);
        holder.mTvTitle.setText(listBean.getTitle());
        holder.mTvDes.setText(listBean.getDescription());
    }

    @Override
    public int getItemCount() {
        return mListBeanList == null ? 0 : mListBeanList.size();
    }

    class ViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_title)
        TextView mTvTitle;
        @BindView(R.id.tv_des)
        TextView mTvDes;

        public ViewHolder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
